<script setup lang="ts">
// import { createGuide, Config } from '../src';
// import '../src/styles/style.css'
// import '../src/styles/theme/dark.css'
import { createGuide, Config } from '@huise513/guide';
import '@huise513/guide/dist/style.css'
import '@huise513/guide/dist/theme/dark.css'
const config: Config = {
  flag: 'data-guide',
  props: { // 所有属性支持在step中配置
    targetClickEnable: false, //目标区域是否可以点击 
    clickTargetNext: false, //点击目标区域自动执行下一步, targetClickEnable需为true
    scrollToTarget: true, //滚动到目标区域
    showSkip: true, //是否显示操作按钮
    nextText: '下一步', //下一步按钮文案
    prevText: '上一步', //上一步按钮文案
    skipText: '跳过', //跳过按钮文案 最后一步之前都展示
    completeText: '完成', //完成按钮文案 只会在最后一步展示
    autoNext: false, //是否自动下一步
    autoNextTime: 5, //自动下一步等待时间(秒)
    // position: 'top', //引导展示位置top/bottom/left/right 默认根据位置自动选择 
  },
  events: {
    onInit() {
      console.log('global onInit');
    },
    onStart() {
      console.log('global onStart');
    },
    beforeStart(next) {
      console.log('global beforeStart');
      next();
    },
    beforeSkip(next) {
      console.log('global beforeSkip');
      next();
    },
    beforeComplete(next) {
      console.log('global beforeComplete');
      next();
    },
    beforeEnter(next) {
      console.log('global beforeEnter');
      next();
    },
    beforeNext(next: Function) {
      console.log('global beforeNext');
      next();
    },
    beforePrev(prev: Function) {
      console.log('global beforePrev');
      prev();
    },
    afterEnter() {
      console.log('global afterEnter');
    },
    onSkip() {
      console.log('global onSkip');
    },
    onComplete() {
      console.log('global onComplete');
    },
    onExit() {
      console.log('global exit');
    }
  },
  steps: [
    {
      tip: `欢迎你Guide
          你好
            你好  
              开始`,
      beforeNext(next: Function) {
        console.log('beforeNext');
        next()
      },
      beforeEnter(next: Function) {
        console.log('beforeEnter');
        next();
      },
      afterEnter() {
        console.log('afterEnter');
      },
    },
    {
      id: 'step1',
      tip: '<div style="color: red;">自动下一步</div>',
      autoNext: true,
      beforePrev(prev: Function) {
        console.log('beforePrev'); prev()
      },
      afterEnter(){
        updateTheme()
      }
    },
    {
      id: 'step60',
      tip: '不显示上一步和跳过',
      showPrevBtn: false,
      showSkip: false,
      position: 'left',
    },
    {
      id: () => document.querySelector('[data-guide="step90"]'),
      tip: '提示文案！',
    },
    {
      id: 'step40',
      tip: '提示文案40',
    },
    {
      tip: '结束了',
    }
  ],
}
function updateTheme(){
  guide && guide.updateConfig({
    theme: 'dark'
  })
}
const guide = createGuide(config);
function start() {
  guide.start();
  console.log('guide', guide);

}
</script>

<template>
  <button @click="start">开始引导</button>
  <div class="boder">
    <div v-for="i in 50" :key="i" class="block" :data-guide="`step${i}`">步骤{{ i }}</div>
  </div>
  <div class="wrap boder">
    <div v-for="i in 100" :key="i" class="block" :data-guide="`step${i + 50}`">步骤{{ i + 50 }}</div>
  </div>
</template>
<style>
body {
  /* background-color: #333; */
}
</style>
<style scoped>
.place-block {
  height: 300px;
  background-color: green;
}

.boder {
  border: 1px solid #ccc;
  padding: 100px;
}

.wrap {
  width: 100%;
  height: 200px;
  overflow-y: auto;
}

.block {
  display: inline-block;
  width: 100px;
  height: 100px;
  margin: 10px;
  border: 1px solid #ccc;
  cursor: pointer;
  /* background-color: #aaa; */
  /* color: #fff */
}
</style>

